package com.scu.bank.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scu.bank.model.dao.NoticeDao;
import com.scu.bank.model.example.NoticeExample;
import com.scu.bank.model.pojo.Notice;
import com.scu.bank.model.base.BaseServiceImpl;
import com.scu.bank.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by pmeng on 2021/01/04.
 */
@Service
@Transactional
public class NoticeServiceImpl extends BaseServiceImpl<Notice,NoticeDao> implements NoticeService {
    @Autowired
    private NoticeDao sysNoticeDao;

    @Override
    public NoticeDao getDao() {
        return sysNoticeDao;
    }

    @Override
    public PageInfo<Notice> list(Integer page, Integer size) {
        PageHelper.startPage(page, size);
        NoticeExample example = new NoticeExample();
        example.createCriteria().andIsDelEqualTo(false);
        PageInfo pageInfo = new PageInfo(sysNoticeDao.selectByExample(example));
        return pageInfo;
    }

    @Override
    public List<Notice> getNotice() {
        return sysNoticeDao.getNotice();
    }
}
